const readlindSync = require('readline-sync');
const judge = require('./judge');
const addid = require('./addid');
const printScore = require('./printScore');
const exit=require('./exit');

function interface(){
    let str =`1. 添加学生\n`+
    `2. 生成成绩单\n`+
    `3. 退出\n`+
    `请输入你的选择（1～3）：`;
    console.log(str);
}
function addStudent(){
    let student = [];
    let s = judge.studentinfor();
    student.push(s);
    console.log("学生添加成功!");
    console.log("继续添加？1.Yes.2.No");
    let choice = readlindSync.question();
    if(choice === '1'){
        return student.concat(addStudent());
    }else{
        return student ;
    }
}
module.exports = main;
function main(){
    let student;
    let studentid;
    interface();
    let choice = readlindSync.question();
    while(true){
        if(choice === '1'){
            student = addStudent();
        }else if(choice === '2'){
            studentid = addid();
            if(studentid){
                printScore(student,studentid);
            }
        }
        if(choice==='3'){
            exit();
        }
        interface();
        choice = readlindSync.question();
    }
}
main();